//
//  Student.m
//  UI17_初级数据持久化
//
//  Created by dllo on 15/12/1.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "Student.h"

@implementation Student

- (void)dealloc
{
    [_name release];
    [_sex release];
    [super dealloc];
}

- (void)encodeWithCoder:(NSCoder *)aCoder;
{
    [aCoder encodeObject:self.name forKey:@"name"];
    [aCoder encodeObject:self.sex forKey:@"sex"];
    // key值并不一定跟属性同名,只为了在反归档时能够找到对应上即可
    [aCoder encodeInteger:self.num forKey:@"学号"];
    [aCoder encodeFloat:self.score forKey:@"score"];
}


- (id)initWithCoder:(NSCoder *)aDecoder;
{
    self = [super init];
    if (self) {
        self.name = [aDecoder decodeObjectForKey:@"name"];
        self.sex = [aDecoder decodeObjectForKey:@"sex"];
        self.num = [aDecoder decodeIntegerForKey:@"学号"];
        self.score = [aDecoder decodeFloatForKey:@"score"];
    }
    return self;
}

@end
